home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / Updates / PowerPC / chunkyppc / test.c < prev   
C/C++ Source or Header  |  2000-05-16  |  6KB  |  288 lines

  1. // This is a highly configurable example :)
  2.  
  3. #define AGA         // For AGA
  4. #undef EGCS_WARPUP  // StormC or vbcc-WarpUP
  5. #define REALLIB     // Use Shared Library, not linker-lib
  6. #define RTGM        // Use rtgmaster
  7. #define PPC         // Use rtgmaster PPC
  8. #ifndef AGA
  9. #ifndef RTGM
  10. #define CGX
  11. #endif
  12. #endif
  13.  
  14. #ifdef RTGM
  15. struct RTGMasterBase *RTGMasterBase=0;
  16. #endif
  17.  
  18. #ifdef RTGM
  19. #ifdef EGCS_WARPUP
  20. #error RTGMaster includes not (yet) available for EGCS WarpUP !!!
  21. #endif
  22. #endif
  23.  
  24. #ifdef CGX
  25. #include <clib/cybergraphics_protos.h>
  26. #endif
  27. #include <clib/intuition_protos.h>
  28. #include <intuition/intuition.h>
  29. #include <clib/exec_protos.h>
  30. #ifdef CGX
  31. #include <cybergraphics/cybergraphics.h>
  32. #endif
  33. #include <clib/dos_protos.h>
  34. #ifdef RTGM
  35. #include <clib/rtgmaster_protos.h>
  36. #include <rtgmaster/rtgmaster.h>
  37. #include <rtgmaster/rtgsublibs.h>
  38. #endif
  39.  
  40. #ifdef REALLIB
  41. #include <clib/chunkyppc_protos.h>
  42. #else
  43. #ifndef EGCS_WARPUP
  44. #include <clib/linkchunkyppc_protos.h>
  45. #else
  46. #error EGCS WARPUP does not support the chunkylib as linkerlibrary !!!
  47. #error Use the shared library version by setting REALLIB !!!
  48. #endif
  49. #endif
  50.  
  51. #ifdef EGCS_WARPUP
  52. #include <inline/cybergraphics.h>
  53. #include <inline/intuition.h>
  54. #include <inline/exec.h>
  55. #include <inline/dos.h>
  56. #include <inline/chunkyppc.h>
  57. #endif
  58.  
  59. #ifndef EGCS_WARPUP
  60. #include <clib/powerpc_protos.h>
  61. #else
  62. #include <powerpc/powerpc_protos.h>
  63. #endif
  64.  
  65. // data is an example data of 8 Bit Data sized 320x256, you would
  66. // of course use your Chunky Buffer for actual code !!!
  67.  
  68. UBYTE data[320*256];
  69.  
  70. #ifdef EGCS_WARPUP
  71. struct Library *IntuitionBase;
  72. struct Library *CyberGfxBase;
  73. struct Library *DOSBase;
  74. struct Library *ChunkyPPCBase;
  75. #else
  76. extern struct Library *IntuitionBase;
  77. struct Library *CyberGfxBase;
  78. extern struct Library *DOSBase;
  79. struct Library *ChunkyPPCBase;
  80. #endif
  81.  
  82. int main()
  83. {
  84.  
  85. #ifndef RTGM
  86.  struct RastPort *rp;
  87.  
  88.  // a Rastport for the Screen
  89. #endif
  90.  
  91. #ifdef CGX
  92.  struct TagItem helpbuf[3];
  93.  
  94.  // To find out VRAM Base
  95. #endif
  96.  
  97. #ifndef RTGM
  98.  struct Screen *myscreen;
  99.  
  100.  // The screen of the example
  101. #else
  102.  struct RtgScreen *MyScreen; 
  103.  struct ScreenReq *ScreenReq=0;
  104.  int wb=0;
  105.  int aga=0;
  106.  struct TagItem ScreenModeTags[]={
  107.     smr_MinWidth,       320,
  108.     smr_MinHeight,      256,
  109.     smr_MaxWidth,       320,
  110.     smr_MaxHeight,      256,
  111.     smr_ChunkySupport,  LUT8,
  112.     smr_PlanarSupport,  Planar8,
  113.     smr_Buffers,        1,
  114.     smr_Workbench,      TRUE,
  115.     smr_PrefsFileName,  (ULONG)"RtgScreenMode.prefs",
  116.     TAG_DONE,           NULL
  117. };
  118.  
  119. struct TagItem RtgTags[]={
  120.    rtg_Draggable,       TRUE,
  121.    rtg_Buffers,         1,
  122.    rtg_Workbench,       0,
  123.    TAG_DONE,            NULL
  124. };
  125.  
  126. struct TagItem GetTags[] = {
  127.     grd_Width,          0,
  128.     grd_Height,         0,
  129.     grd_Depth,          0,
  130.     grd_BytesPerRow,    0,
  131.     grd_PixelLayout,    0,
  132.     grd_ColorSpace,     0,
  133.     grd_PlaneSize,      0,
  134.     TAG_DONE,           NULL
  135. };
  136. #endif
  137.  
  138.  UBYTE *address;
  139.  
  140.  // VRAM Base
  141.  
  142.  int bpr;
  143.  
  144.  // The BytesPerRow (needed for CV64 Support, read above)
  145.  
  146.  int f,g;
  147.  for (f=0;f<320;f++)
  148.  {
  149.   for (g=0;g<256;g++)
  150.   {
  151.    data[f+320*g]=g;
  152.   }
  153.  }
  154.  
  155.  // Some example data for this demonstration of GFX Board Support
  156.  
  157. #ifndef RTGM
  158.  IntuitionBase=OpenLibrary("intuition.library",36);
  159. #endif
  160. #ifdef CGX
  161.  CyberGfxBase=OpenLibrary("cybergraphics.library",0);
  162. #endif
  163.  ChunkyPPCBase=OpenLibrary("chunkyppc.library",0);
  164. #ifdef EGCS_WARPUP
  165.  DOSBase=OpenLibrary("dos.library",0);
  166. #endif
  167. #ifdef RTGM
  168.  RTGMasterBase=(struct Library *)OpenLibrary("rtgmaster.library",34);
  169. #ifdef PPC
  170.     ScreenReq=PPCRtgScreenModeReq(ScreenModeTags);
  171.     if (!ScreenReq)
  172.     {
  173.      exit(0);
  174.     }
  175.     if (ScreenReq->Flags&sq_WORKBENCH)
  176.     {
  177.      RtgTags[2].ti_Data=LUT8;
  178.      wb=1;
  179.      printf("WB Window Mode enabled\n");
  180.     }
  181.     else wb=0;
  182.     MyScreen=PPCOpenRtgScreen(ScreenReq,RtgTags);
  183.     PPCGetRtgScreenData(MyScreen, GetTags);
  184. #else
  185.     ScreenReq=RtgScreenModeReq(ScreenModeTags);
  186.     if (!ScreenReq)
  187.     {
  188.      exit(0);
  189.     }
  190.     if (ScreenReq->Flags&sq_WORKBENCH)
  191.     {
  192.      RtgTags[2].ti_Data=LUT8;
  193.      wb=1;
  194.      printf("WB Window Mode enabled\n");
  195.     }
  196.     else wb=0;
  197.     MyScreen=OpenRtgScreen(ScreenReq,RtgTags);
  198.     GetRtgScreenData(MyScreen, GetTags);
  199. #endif
  200.     bpr=GetTags[3].ti_Data;
  201.     if (GetTags[4].ti_Data==grd_PLANAR) aga=1;
  202.     else aga=0;
  203. #else
  204.  myscreen = OpenScreenTags(0,SA_Width,320,SA_Height,256, SA_Depth,8,TAG_END);
  205.  rp=&(myscreen->RastPort);
  206. #endif
  207.  
  208.  // Screen and RastPort init for demo program
  209.  
  210. #ifdef CGX
  211.  helpbuf[0].ti_Tag=LBMI_BASEADDRESS;
  212.  helpbuf[0].ti_Data=(ULONG)&address;
  213.  helpbuf[1].ti_Tag=LBMI_BYTESPERROW;
  214.  helpbuf[1].ti_Data=(ULONG)&bpr;
  215.  helpbuf[2].ti_Tag=TAG_END;
  216.  helpbuf[2].ti_Data=0;
  217.  UnLockBitMap(LockBitMapTagList(rp->BitMap,helpbuf));
  218. #endif
  219. #ifdef RTGM
  220. #ifdef PPC
  221.  address=PPCLockRtgScreen(MyScreen);
  222. #else
  223.  address=LockRtgScreen(MyScreen);
  224. #endif
  225. #endif
  226.  
  227. #ifndef RTGM
  228. #ifdef AGA
  229.  c2p_1(data,rp->BitMap,320,256);
  230. #else
  231.  if (wb)
  232.  {
  233. #ifdef PPC
  234.   PPCCopyRtgBlit(MyScreen,PPCGetBufAdr(MyScreen,0),data,0,0,0,320,256,320,256,0,0);
  235. #else
  236.   CopyRtgBlit(MyScreen,GetBufAdr(MyScreen,0),data,0,0,0,320,256,320,256,0,0);
  237. #endif
  238.  }
  239.  elseChunkyNoffFastest(address,data,320,256,bpr);
  240.  // Copy the example data
  241. #endif
  242. #else
  243. #ifdef PPC
  244.  if (aga) PPCCopyRtgBlit(MyScreen,PPCGetBufAdr(MyScreen,0),data,0,0,0,320,256,320,256,0,0);
  245. #else
  246.  if (aga) CopyRtgBlit(MyScreen,GetBufAdr(MyScreen,0),data,0,0,0,320,256,320,256,0,0);
  247. #endif
  248.  else ChunkyNoffFastest(address,data,320,256,bpr);
  249. #endif
  250.  
  251.  Delay(300);
  252.  
  253.  // Delay for the demo
  254.  
  255. #ifndef RTGM
  256.  CloseScreen(myscreen);
  257. #else
  258. #ifdef PPC
  259.  if (MyScreen) PPCUnlockRtgScreen(MyScreen);
  260.  if (MyScreen) PPCCloseRtgScreen(MyScreen);
  261.  if (ScreenReq) PPCFreeRtgScreenModeReq(ScreenReq);
  262. #else
  263.  if (MyScreen) UnlockRtgScreen(MyScreen);
  264.  if (MyScreen) CloseRtgScreen(MyScreen);
  265.  if (ScreenReq) FreeRtgScreenModeReq(ScreenReq);
  266. #endif
  267. #endif
  268.  
  269.  // Close the screen again
  270.  
  271.  CloseLibrary(ChunkyPPCBase);
  272. #ifdef CGX
  273.  CloseLibrary(CyberGfxBase);
  274. #endif
  275. #ifndef RTGM
  276.  CloseLibrary(IntuitionBase);
  277. #endif
  278. #ifdef EGCS_WARPUP
  279.  CloseLibrary(DOSBase);
  280. #endif
  281. #ifdef RTGM
  282.  CloseLibrary((struct Library *)RTGMasterBase);
  283. #endif
  284.  
  285.  // Close the libs
  286.  
  287. }
  288.